package seven.test_7_25;

import java.util.*;

public class TestMain1 {
    public static Set<Integer> set = new HashSet<>();
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int count = 0;
        for (int i = a; i <= b; i++) {
            if(i > 10) {
                if(getMiraculous(i)) {
                    count++;
                }
            }
        }
        System.out.println(count);
    }
    private static boolean getMiraculous(int n) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        int count = 0;
        while (n > 0) {
            arrayList.add(n % 10);
            n /= 10;
        }
        for (int i = 0; i < arrayList.size(); i++) {
            if(arrayList.get(i) == 0) {
                continue;
            }
            for (int j = 0; j < arrayList.size(); j++) {
                if(i != j) {
                    int x = arrayList.get(i);
                    int y = arrayList.get(j);
                    if(isPrime(x*10 + y)) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
    private static boolean isPrime(int n) {
        for (int i = 2; i < n / 2; i++) {
            if(n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
